feat: upgrade deps, new prefix option, cleaning and typos#15
feat: upgrade deps, new prefix option, cleaning and typos#15GreyXor wants to merge 19 commits intooapi-codegen:mainfrom
Conversation
|
@jamietanna gentle ping, can I have your input here ? |
|
@jamietanna hello ? |
|
Hey @GreyXor apologies for the delay! Out of interest, how's your testing for this going so far? I've tried to take the Prefix functionality and add it into the -want:
+got:
# A request that is well-formed is passed through to the Handler
-POST /public-api/v1/resource was called
-Received an HTTP 204 response. Expected HTTP 204
+Received an HTTP 404 response. Expected HTTP 204
+Response body: no matching operation was found
|
|
Hello thanks, |
|
Hello @jamietanna, I'm not using echo anymore, I switched to nethttp. |
Add a Prefix field to Options that strips a path prefix before OpenAPI validation. This allows APIs mounted under a sub-path (e.g. "/api") to validate correctly against specs whose paths don't include the prefix. The request is cloned before modification so downstream handlers still see the original path. Closes oapi-codegen#11 Supersedes oapi-codegen#15 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I'm closing this PR, but I cherry picked and fixed up your code for |
Add a Prefix field to Options that strips a path prefix before OpenAPI validation. This allows APIs mounted under a sub-path (e.g. "/api") to validate correctly against specs whose paths don't include the prefix. The request is cloned before modification so downstream handlers still see the original path. Closes #11 Supersedes #15 Co-authored-by: GreyXor <greyxor@protonmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Great! thank you |
|
@mromaszewicz can you please amend existing PRs instead of raising fresh ones if updating someone else's? It means the author still gets a "PR merged" indication, and is how we've been doing this for a couple of years |
Hello, this PR contains a few improvements:
anyrather thaninterface{}orhttp.NoBody, rather thannilThis new prefix option is useful when you have an API whose server spec contains a subfolder. In my case, it's
/api. But as I register my api withserver.RegisterHandlersWithBaseURL(s.EchoServer, server.NewStrictHandler(s.APIService.API, nil), "/api").The prefix is not visible to the router, so the validator can't see it either. Setting this new option to
/apivirtually removes the prefix. And makes the validator work properly.close: #11